local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


	if msgcontains(msg, 'fire') then
			selfSay('Oh, yes! I love the fire, but loose my eternal {flames}.' , cid)
			talkState[talkUser] = 1
		end

	if msgcontains(msg, 'mission') then
		if getPlayerStorageValue(cid,15202) == 1 then		
			selfSay('Are you so crazy? Where are my Eternal Flames?', cid)
		elseif getPlayerStorageValue(cid,15202) == 2 then		
			selfSay('I can\'t belive!!! You realy found the Eternal Flames?', cid)
			talkState[talkUser] = 3
		end

	elseif talkState[talkUser] == 1 then
			if msgcontains(msg, 'flames') then
			selfSay('Really? Can you find it to me?', cid)
			talkState[talkUser] = 2
		end
		
	elseif talkState[talkUser] == 2 then
			if msgcontains(msg, 'yes') then
			selfSay('Let\'s go! Enter in the Hall of Fire and take my Eternal Flames!. Then report to me about your mission.', cid)
			setPlayerStorageValue(cid,15202,1)
		end

	elseif talkState[talkUser] == 3 then
			if msgcontains(msg, 'yes') then
   			doPlayerRemoveItem(cid,8304,1)
			selfSay('Thank you!', cid)
			setPlayerStorageValue(cid,15201,2)
		end

	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())